package br.unipar.lhmicheletti.controller;

import java.util.Map;

import javax.faces.context.FacesContext;

public class AutenticacaoController {
	
	private String email, senha;
	
	public boolean getAutenticado(){
		
		String usuario = (String)getSession().get( "usuario" );
		
		return ( usuario != null );
	}
	
	public Map<String, Object> getSession(){
		
		return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
	}
	
	public String acessar(){
		
		if ( ( email != null ) && ( !email.trim().equals("") ) ){
			
			
			getSession().put( "usuario", email );
		}
		
		return "INDEX";
	}
	
	public String sair(){
		getSession().clear();
		
		return "INDEX";
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

}
